home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-17 | 3.8 KB | 104 lines | [TEXT/MSWD] |
- This archive contains p2c, a pascal to C translator. It reads from
- standard input and writes to standard output. That means that after
- you start the program, you must choose 'File' from the options below
- 'Standard Input' to select the pascal file, and 'file' from the
- options below 'Standard Output' to choose the C destination file.
-
- P2C is *NOT* meant to do program development, and will only produce
- correct output if your pascal program conforms to ISO level 0
- pascal. If your input file does not conform to this standard, the
- program will quit, and will in many cases not produce an
- understandable error message. The program bails out at the first error
- message. The resulting output is not very comprehensible, unless you
- know what a static link is.
-
- Usage on the macintosh for porting Mac applications written in pascal
- is thus a tricky job. Every function, type and constant that is not
- declared or defined will be considered an error. So, if you use e.g. a
- ToolBox routine like GetNextEvent, you will need to include a (empty)
- function definition for GetNextEvent, and write (part of) its data
- types as well. This can be quite a lot of work... Perhaps it is
- possible to adapt the program in such a way that it will skip
- declaration errors, but that would require a serious adapation of the
- source code. The source code is available on request, but was
- originally written in pascal and ported to c using p2c, so it is
- rather obscure.
-
- I did not write the program, only port it to the mac. The original
- sources (also known as ptoc) must be available elsewhere.
-
- Anyway, enjoy it.
-
- Theo Vosse
- ----------
- Unit for Experimental Psychology
- University of Leiden
- The Netherlands
-
- PS Here is the original manual page:
-
- --------------------------------------------------------------------------------
-
-
-
- P2C(1)
-
-
-
- NAME
- p2c - Pascal to C translator
-
- SYNOPSIS
- p2c < pascal source > c source
-
- DESCRIPTION
- P2c reads a correct Pascal program and prints a C program with the same
- behaviour. It is intended as a tool for transporting finished applica-
- tions to environments that lack Pascal compilers, it is not intended for
- program development.
-
- The input should comply with the ISO level 0 Pascal definition. Two
- common Pascal extensions are also recognized: the keyword otherwise may
- be used for default entries in case-statements, the keyword external may
- be used in place of the forward directive to signify that a procedure or
- function is defined in a library. Furthermore, the translator does not
- require a complete Pascal program, a consistent subset of declarations
- can be translated. Thus a primitive module concept is supported.
-
- SEE ALSO
- P2c implementation notes.
-
- CAVEATS
- The quality of an object program is of course highly dependent on the C
- compiler that processes the translated code. Arithmetic operations are
- sometimes implemented in a way that is incompatible with the Pascal
- definition. For example, the translator assumes that:
-
- a := b mod c
-
- can be accurately translated into
-
- a = b % c
-
- but that may not be true if c is negative. A check on the characteris-
- tics of integer and float arithmetic is strongly recommended.
-
- Some Pascal constructs are impossible to express in C. The translator
- will not object to:
-
- type ptr = ^ ptr;
-
- but a C-compiler may balk at the resulting:
-
- typedef ptr * ptr;
-
-
- BUGS
- The program can't translate comments from Pascal to C.
-
- The translator does not do complete typechecking so a Pascal program
- that isn't formally correct may cause malfunction.
-
- Passing a procedure as parameter to an enclosing recursive procedure may
- produce erroneous code (see the implementation notes).
-